from pyfpdf import fpdf
import commands
""" Contains the header and footer definitions for the PDF output"""

class MyPDF(fpdf.FPDF):
    """Sets PDF Output Header and Footer"""
     #----------------------------------------------------------------------
    def header(self):
        """
        Header on each page
        """
        # insert my logo
        self.image("logo.png", x=10, y=8, w=23)
        # position logo on the right
        self.cell(w=70)
 
        # set the font for the header, B=Bold
        self.set_font("Arial", style="B", size=10)
        # page title
        self.cell(63,10, "Active Connections\n"+commands.getoutput("/bin/date +%d/%m/%Y-%R"), border=1, ln=0, align="C")
        # insert a line break of 20 pixels
        self.ln(20)
 
    #----------------------------------------------------------------------
    def footer(self):
        """
        Footer on each page
        """
        # position footer at 15mm from the bottom
        self.set_y(-15)
 
        # set the font, I=italic
        self.set_font("Arial", style="I", size=8)
 
        # display the page number and center it
        pageNum = "Page %s/{nb}" % self.page_no()
        self.cell(0, 10, pageNum, align="C")
